function fft_data = FUN_plotDataFilter(fig,data )
%FUN_plotDataFreq Summary of this function goes here
%   Detailed explanation goes here

size = length(data);
sampletime = 0.01                               %sample time that unit is second
t = 0:sampletime:(size-1) * sampletime;     %time point

figure(fig);clf();subplot(2,2,1);
plot(t,data,'k');
title('Time Domain Analysis');axis([0 60 -200 200]);
xlabel('Time/s'); ylabel('Amplitude/Value')

samplefreq = 1/sampletime                        %sample frequency that unit is Hz
f = (0:(size-1))/size*samplefreq;           %frequency point
fft_data=fft(data);
fft_data_abs=abs(fft_data);

figure(fig);subplot(2,2,3);
plot(f,fft_data_abs,'k');
title('Frequency domain orignal PPG data ');

data = data - data(1);
% Hd = bandpassfilter;
Hd = lowpassfilter;
flitered_data = filter(Hd,data);

flitered_data = detrend(flitered_data,'linear',30);
% data_pretrend = IIR_datafilter_success(data);
% [p,s,mu] = polyfit((1:ppg_size),data_pretrend,6);
% f_y = polyval(p,(1:ppg_size),[],mu);
% ppg_fliterdata = ppg_data_pretrend - f_y;        % Detrend data

figure(fig);subplot(2,2,2);
plot(f,flitered_data,'b');
title('Time Domain Filtered Analysis');axis([0 60 -200 200]);
xlabel('Time/s'); ylabel('Amplitude/Value')

fft_flitered_data=fft(flitered_data);
figure(fig);subplot(2,2,4);
plot(f,abs(fft_flitered_data),'b');
title('Frequency Domain filtered Analysis');axis auto %axis([0 100 0 10^6]);
xlabel('Frequency/Hz'); ylabel('Amplitude/Value')

end

